<template>
  <div>

    <!--    表格-->
    <el-table :data="truckData.items">
      <el-table-column label="车辆类型id">
        <template slot-scope="scope">
          <el-select v-model="scope.row.truckTypeId" placeholder="请选择" disabled>
            <el-option v-for="(item,index) in truckTypeData" :label="item.name" :key="index" :value="item.id"/>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="所属车队id" prop="fleetId" >
        <template slot-scope="scope">
          <el-select v-model="scope.row.fleetId" placeholder="请选择" disabled>
            <el-option v-for="(item,index) in fleetData" :label="item.name" :key="index" :value="item.id"/>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="品牌" prop="brand"/>
      <el-table-column label="车牌号码" prop="licensePlate"/>
      <el-table-column label="GPS设备id" prop="deviceGpsId"/>
      <el-table-column label="准载重量(千克)" prop="allowableLoad"/>
      <el-table-column label="准载体积(方)" prop="allowableVolume"/>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <p v-if="scope.row.status==1">正常</p>
          <p v-if="scope.row.status==0">禁用</p>
        </template>
      </el-table-column>
    </el-table>
    <!--    分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="Number(truckData.page)"
      :page-sizes="[5, 10, 30, 50]"
      :page-size="Number(truckData.pageSize)"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(truckData.counts)"
    >
    </el-pagination>
  </div>
</template>

<script>
import truck from '@/api/base/truck/index'

export default {
  name: 'index',
  data() {
    return {
      //车辆类型数据
      truckTypeData: [],
      //车队数据
      fleetData: [],
      truckData: {},
      pageNum: 1,
      pageSize: 5
    }
  }, methods: {
    handleSizeChange(val) {
      this.pageSize = val
      this.findAllPage()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.findAllPage()
    },
    findAllPage() {
      truck.findAllPage(this.pageNum, this.pageSize).then(data => {
        this.truckData = data.data
      })
    },//获取车辆类型
    getAllTruckType() {
      truck.getAllTruckType().then(data => {
        this.truckTypeData = data.data
      })
    },
    //获取车队
    getAllFleet() {
      truck.getAllFleet().then(data => {
        this.fleetData = data.data
      })
    }

  }, mounted() {
    this.findAllPage();
    this.getAllTruckType()
    this.getAllFleet()
  }
}
</script>

<style scoped>

</style>
